package testSudoku;

import static org.junit.Assert.assertArrayEquals;

import org.junit.Test;
import sudoku.Sudoku_Question;
import sudoku.easy_qustion;
import sudoku.medium_qustion;
import sudoku.hard_qustion;

public class testSudoku_Question {
	
	private Sudoku_Question sudoku_Question;
	
	@Test
	public void test_get_questn_easy() 
	{
		sudoku_Question=new easy_qustion();
		char[][][] get_questn = sudoku_Question.get_questn();
		
		char [][]expect_result = new char[][] {
				{'4','6','3','2',' ','9','7','1','8'},//array[0][0-8]
				{'7',' ',' ',' ',' ',' ',' ',' ','5'},//array[1][0-8]
				{'8',' ','5','7',' ','3','6',' ','2'},//array[2][0-8]
				{'3',' ','8','6',' ','2','5',' ','1'},//array[3][0-8]
				{' ','7',' ',' ','4',' ',' ','6',' '},//array[4][0-8]
				{'6',' ','2','3',' ','1','4',' ','9'},//array[5][0-8]
				{'2',' ','7','9',' ','4','1',' ','6'},//array[6][0-8]
				{'9',' ',' ',' ',' ',' ',' ',' ','4'},//array[7][0-8]
				{'5','8','4','1',' ','6','3','9','7'} //array[8][0-8]
		};
		assertArrayEquals(expect_result, get_questn[0]);
	}
	
	@Test
	public void test_get_questn_medium() 
	{
		sudoku_Question=new medium_qustion();
		char[][][] get_questn = sudoku_Question.get_questn();
		
		char [][]expect_result = new char[][] {
				{' ',' ','6',' ',' ',' ','3',' ',' '},
				{' ','3',' ','4',' ','8',' ','1',' '},
				{'4','1','5',' ',' ',' ',' ','8','2'},
				{' ',' ','4','3',' ','1','2','6',' '},
				{'1',' ',' ',' ','4',' ',' ',' ','3'},
				{' ','7','8','2',' ','5','1',' ',' '},
				{'5','2',' ',' ',' ',' ','6','9','8'},
				{' ','4',' ','8',' ','3',' ','2',' '},
				{' ',' ','7',' ',' ',' ','4',' ',' '}
		};
		assertArrayEquals(expect_result, get_questn[0]);
	}
	
	@Test
	public void test_get_questn_hard() 
	{
		sudoku_Question=new hard_qustion();
		char[][][] get_questn = sudoku_Question.get_questn();
		
		char [][]expect_result = new char[][] {
				{' ',' ',' ','2','9','1',' ',' ',' '},
				{'4',' ',' ','5',' ','3',' ',' ','7'},
				{' ',' ','3',' ',' ',' ','8',' ',' '},
				{'7',' ','4',' ','2',' ','1',' ','9'},
				{' ','8',' ',' ',' ',' ',' ','5',' '},
				{'2',' ','1',' ','4',' ','6',' ','3'},
				{' ',' ','2',' ',' ',' ','3',' ',' '},
				{'3',' ',' ','9',' ','2',' ',' ','6'},
				{' ',' ',' ','4','3','6',' ',' ',' '}
		};
		assertArrayEquals(expect_result, get_questn[0]);
	}
	
	@Test
	public void test_get_sol_easy() 
	{
		sudoku_Question=new easy_qustion();
		char[][][] get_sol = sudoku_Question.get_sol();
		char [][]expect_result = new char[][] {
				{'4','6','3','2','5','9','7','1','8'},
				{'7','2','1','4','6','8','9','3','5'},
				{'8','9','5','7','1','3','6','4','2'},
				{'3','4','8','6','9','2','5','7','1'},
				{'1','7','9','8','4','5','2','6','3'},
				{'6','5','2','3','7','1','4','8','9'},
				{'2','3','7','9','8','4','1','5','6'},
				{'9','1','6','5','3','7','8','2','4'},
				{'5','8','4','1','2','6','3','9','7'}
		};
		assertArrayEquals(expect_result, get_sol[0]);
	}
	
	@Test
	public void test_get_sol_medium() 
	{
		sudoku_Question=new medium_qustion();
		char[][][] get_sol = sudoku_Question.get_sol();
		char [][]expect_result = new char[][] {
				{'2','8','6','5','1','9','3','7','4'},
				{'7','3','9','4','2','8','5','1','6'},
				{'4','1','5','7','3','6','9','8','2'},
				{'9','5','4','3','8','1','2','6','7'},
				{'1','6','2','9','4','7','8','5','3'},
				{'3','7','8','2','6','5','1','4','9'},
				{'5','2','3','1','7','4','6','9','8'},
				{'6','4','1','8','9','3','7','2','5'},
				{'8','9','7','6','5','2','4','3','1'}
		};
		assertArrayEquals(expect_result, get_sol[0]);
	}
	
	@Test
	public void test_get_sol_hard() 
	{
		sudoku_Question=new hard_qustion();
		char[][][] get_sol = sudoku_Question.get_sol();
		char [][]expect_result = new char[][] {
				{'8','6','7','2','9','1','5','3','4'},
				{'4','1','9','5','8','3','2','6','7'},
				{'5','2','3','7','6','4','8','9','1'},
				{'7','3','4','6','2','5','1','8','9'},
				{'9','8','6','3','1','7','4','5','2'},
				{'2','5','1','8','4','9','6','7','3'},
				{'6','9','2','1','7','8','3','4','5'},
				{'3','4','8','9','5','2','7','1','6'},
				{'1','7','5','4','3','6','9','2','8'}
		};
		assertArrayEquals(expect_result, get_sol[0]);
	}
	
	@Test
	public void test_get_question_easy() 
	{
		sudoku_Question=new easy_qustion();
		char[][] get_question = sudoku_Question.get_question(0);
		char [][]expect_result = new char[][] {
				{'4','6','3','2',' ','9','7','1','8'},//array[0][0-8]
				{'7',' ',' ',' ',' ',' ',' ',' ','5'},//array[1][0-8]
				{'8',' ','5','7',' ','3','6',' ','2'},//array[2][0-8]
				{'3',' ','8','6',' ','2','5',' ','1'},//array[3][0-8]
				{' ','7',' ',' ','4',' ',' ','6',' '},//array[4][0-8]
				{'6',' ','2','3',' ','1','4',' ','9'},//array[5][0-8]
				{'2',' ','7','9',' ','4','1',' ','6'},//array[6][0-8]
				{'9',' ',' ',' ',' ',' ',' ',' ','4'},//array[7][0-8]
				{'5','8','4','1',' ','6','3','9','7'} //array[8][0-8]
		};
		assertArrayEquals(expect_result, get_question);
	}

	@Test
	public void test_get_question_medium() 
	{
		sudoku_Question=new medium_qustion();
		char[][] get_question = sudoku_Question.get_question(0);
		char [][]expect_result = new char[][] {
				{' ',' ','6',' ',' ',' ','3',' ',' '},
				{' ','3',' ','4',' ','8',' ','1',' '},
				{'4','1','5',' ',' ',' ',' ','8','2'},
				{' ',' ','4','3',' ','1','2','6',' '},
				{'1',' ',' ',' ','4',' ',' ',' ','3'},
				{' ','7','8','2',' ','5','1',' ',' '},
				{'5','2',' ',' ',' ',' ','6','9','8'},
				{' ','4',' ','8',' ','3',' ','2',' '},
				{' ',' ','7',' ',' ',' ','4',' ',' '}
		};
		assertArrayEquals(expect_result, get_question);
	}
	
	@Test
	public void test_get_question_hard() 
	{
		sudoku_Question=new hard_qustion();
		char[][]get_question = sudoku_Question.get_question(0);
		
		char [][]expect_result = new char[][] {
				{' ',' ',' ','2','9','1',' ',' ',' '},
				{'4',' ',' ','5',' ','3',' ',' ','7'},
				{' ',' ','3',' ',' ',' ','8',' ',' '},
				{'7',' ','4',' ','2',' ','1',' ','9'},
				{' ','8',' ',' ',' ',' ',' ','5',' '},
				{'2',' ','1',' ','4',' ','6',' ','3'},
				{' ',' ','2',' ',' ',' ','3',' ',' '},
				{'3',' ',' ','9',' ','2',' ',' ','6'},
				{' ',' ',' ','4','3','6',' ',' ',' '}
		};
		assertArrayEquals(expect_result, get_question);
	}
	@Test
	public void test_get_solution_easy() 
	{
		sudoku_Question=new easy_qustion();
		char[][] get_solution = sudoku_Question.get_solution(0);
		char [][]expect_result = new char[][] {
				{'4','6','3','2','5','9','7','1','8'},
				{'7','2','1','4','6','8','9','3','5'},
				{'8','9','5','7','1','3','6','4','2'},
				{'3','4','8','6','9','2','5','7','1'},
				{'1','7','9','8','4','5','2','6','3'},
				{'6','5','2','3','7','1','4','8','9'},
				{'2','3','7','9','8','4','1','5','6'},
				{'9','1','6','5','3','7','8','2','4'},
				{'5','8','4','1','2','6','3','9','7'}
		};
		assertArrayEquals(expect_result, get_solution);
	}
	
	@Test
	public void test_get_solution_medium() 
	{
		sudoku_Question=new medium_qustion();
		char[][] get_solution = sudoku_Question.get_solution(0);
		char [][]expect_result = new char[][] {
				{'2','8','6','5','1','9','3','7','4'},
				{'7','3','9','4','2','8','5','1','6'},
				{'4','1','5','7','3','6','9','8','2'},
				{'9','5','4','3','8','1','2','6','7'},
				{'1','6','2','9','4','7','8','5','3'},
				{'3','7','8','2','6','5','1','4','9'},
				{'5','2','3','1','7','4','6','9','8'},
				{'6','4','1','8','9','3','7','2','5'},
				{'8','9','7','6','5','2','4','3','1'}
		};
		assertArrayEquals(expect_result, get_solution);
	}
	
	@Test
	public void test_get_solution_hard() 
	{
		sudoku_Question=new hard_qustion();
		char[][] get_solution = sudoku_Question.get_solution(0);
		char [][]expect_result = new char[][] {
				{'8','6','7','2','9','1','5','3','4'},
				{'4','1','9','5','8','3','2','6','7'},
				{'5','2','3','7','6','4','8','9','1'},
				{'7','3','4','6','2','5','1','8','9'},
				{'9','8','6','3','1','7','4','5','2'},
				{'2','5','1','8','4','9','6','7','3'},
				{'6','9','2','1','7','8','3','4','5'},
				{'3','4','8','9','5','2','7','1','6'},
				{'1','7','5','4','3','6','9','2','8'}
		};
		assertArrayEquals(expect_result, get_solution);
	}
}
